package cn.tedu.controller;

import cn.tedu.dao.StudentDao;
import cn.tedu.entity.Student;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "UpdateServlet",urlPatterns = "/update")
public class UpdateServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id=request.getParameter("id");
        String name=request.getParameter("name");
        String department=request.getParameter("department");
        String grade=request.getParameter("grade");
        String student=request.getParameter("student");
        System.out.println(id+name+department+grade+student);
        Student student1=new Student(Integer.parseInt(id),name,department,Integer.parseInt(grade),Integer.parseInt(student));
        StudentDao dao=new StudentDao();
        dao.update(student1);
        response.sendRedirect(request.getContextPath()+"list");


    }
}
